package com.smartstate.admin.biz.entity.bo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.smartstate.admin.biz.entity.dto.RoleDto;
import com.smartstate.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.persistence.Entity;
import java.io.Serializable;

@Data
@Entity
@NoArgsConstructor
@TableName("role")
@ApiModel(value = "Role",description = "角色设置")
public class Role extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 角色名称
     */
    private String roleName;

    /**
     * 角色编号
     */
    private String roleCode;

    /**
     * 描述
     */
    private String description;

    /**
     * 角色类型 1:后台角色 0:前台角色
     */
    private Integer roleType;

    /**
     * 是否有效(0无效，1有效)
     */
    private Integer status;
    /**
     * 企业id
     */
    private String enterpriseId;

    /**
     * dto转bo
     */
    public Role buildBo(RoleDto roleDto){
        BeanUtils.copyProperties(roleDto,this);
        return this;
    }

    public Role(String roleName, String roleCode, String description, String enterpriseId) {
        this.roleName = roleName;
        this.roleCode = roleCode;
        this.description = description;
        this.roleType = 1;
        this.status = 1;
        this.enterpriseId = enterpriseId;
    }
}
